const express = require('express');
const bodyParser = require('body-parser');

const server = express();
server.use(bodyParser.urlencoded({ extended: false }));
server.use(bodyParser.json())

server.use(express.static(__dirname));

// 导入模块
const index = require('./index');
const ddz = require('./index_ddz');
const { editUser } = require('./editUser');

server.use(async (req, res, next) => {
    // 允许所有请求
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization");
    next();
});

// 麻将
server.use('/getSortGameList', (req, res) => { index.entry(req, res); })
server.use('/editUserName', (req, res) => { editUser(req, res); })

// 斗地主
server.use('/getDdzSortGameList', (req, res) => { ddz.entry(req, res); })

server.use('/test', (req, res) => {
    res.send('test successfully ......')
})

server.listen(11111);